package com.haircut.project.vo.salary;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Optional;

@Setter
@Getter
public class ApiSalaryResVo {
    @ApiModelProperty("工资id")
    private String id;

    /**
     *  工资编号
     */
    @ApiModelProperty("工资编号")
    private String salaryNo;

    /**
     * 总金额
     */
    @ApiModelProperty("总金额")
    private BigDecimal totalAmount;
    /**
     * 优惠金额
     */
    @ApiModelProperty("优惠金额")
    private BigDecimal discountAmount;
    /**
     * 工资类型(1、待发 2、已发)
     */
    @ApiModelProperty("工资类型(1、待发 2、已发)")
    private Integer salaryType;


    /**
     * 技师总现金金额
     */
    @ApiModelProperty("技师总现金金额")
    private BigDecimal techCashAmount;
    /**
     * 技师总刷卡金额
     */
    @ApiModelProperty("技师总刷卡金额")
    private BigDecimal techCardAmount;


    /**
     * 小费总刷卡金额
     */
    @ApiModelProperty("小费总刷卡金额")
    private BigDecimal tipsCardAmount;


    /**
     * 小费总现金金额
     */
    @ApiModelProperty("工资总现金金额")
    private BigDecimal salaryCashAmount;
    /**
     * 小费总刷卡金额
     */
    @ApiModelProperty("工资总刷卡金额")
    private BigDecimal salaryCardAmount;

    /**
     * 方法时间
     */
    @ApiModelProperty("发放时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss", timezone = "America/Los_Angeles")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date payDate;

    @ApiModelProperty("确认时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss", timezone = "America/Los_Angeles")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date confirmDate;

    @ApiModelProperty("确认描述")
    private String confirmRemark;

    public void calc(){
        this.techCardAmount = Optional.ofNullable(techCardAmount).orElse(BigDecimal.ZERO);
        this.techCashAmount = Optional.ofNullable(techCashAmount).orElse(BigDecimal.ZERO);
        this.tipsCardAmount = Optional.ofNullable(tipsCardAmount).orElse(BigDecimal.ZERO);
        this.salaryCardAmount = this.techCardAmount.add(this.tipsCardAmount);
    }

}
